package com.juc.cas;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Author Zan
 * @Create 2024/5/10 22:56
 * @ClassName: CASDemo
 * @Description : TODO 请用一句话描述该类的功能
 */
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);

        //  expect 期望值，update 更新值
        System.out.println(atomicInteger.compareAndSet(5, 2022) + "\t" + atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5, 2022) + "\t" + atomicInteger.get());
    }
}
